package com.qcby.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author haozeWang
 * @create 2021-08-21 10:38
 */
@Controller
@RequestMapping("/router")
public class SystemController {

    /*跳转到后台首页*/
    @RequestMapping("/toindex")
    public ModelAndView toIndex(HttpServletRequest request, HttpServletResponse response){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("index");
        Object name=request.getSession().getAttribute("username");
        mv.addObject("username",name);
        return mv;
    }

    /*跳转到默认系统参数页面*/
    @RequestMapping("/tomain")
    public String toMain(){
        return "main";
    }
    /*登出操作*/
    @RequestMapping("/logout")
    public String logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
        /*将session中username置空*/
        request.getSession().setAttribute("username",null);
        /*退回login页面*/
        return "forward:/login.jsp";
    }
    /*跳转到学生列表页*/
    @RequestMapping("/tostudentlist")
    public String tostudentList(){
        return "studentList";
    }
    /*跳转到班级列表页*/
    @RequestMapping("/toclasslist")
    public String toClassList(){
        return "classList";
    }
    /*跳转到教师列表页*/
    @RequestMapping("/toteacherlist")
    public String toTeacherList(){
        return "teacherList";
    }

    /*跳转到学生添加页*/
    @RequestMapping("/tostudentadd")
    public String tostudentadd(){
        return "studentAdd";
    }
    /*跳转到教师添加页*/
    @RequestMapping("/toteachersadd")
    public String toteachersadd(){
        return "teachersAdd";
    }
    /*跳转到班级添加页*/
    @RequestMapping("/toclassadd")
    public String toclassadd(){
        return "classAdd";
    }

}
